-- https://github.com/folke/which-key.nvim


local wk = require("which-key")

-- 插件命令分组
local mappings = {
    l = {
        name = "Lspsaga",
        r = {"重命名"},
        x = {"code action"},
        f = {"定义和引用"},
        e = {'光标下的错误浮窗口'},
        j = {'下一个错误'},
        k = {'上一个错误'},
    },
    c = {
        name = "Lsp",
        r = {"重命名"},
        x = {"code action"},
        d = { "定义(definition)" },
        D = { "声明(declaration)" },
        m = { "实现(implementation)" },
        H = { "帮助(signature_help)" },
        h = { "文档浮窗(hover)" },
        ['='] = { "格式化(Format)" },
        ['wa'] = { "增加工作区(Add workspace folder)" },
        ['wr'] = { "删除工作区(Remove workspace folder)" },
        ['wl'] = { "工作区列表(List workspace)" },
        f = { "引用" },
        ['i'] = { "Connected Language Servers"},
        ['4'] = { "set loclist" },
        ['5'] = { "set qflist" },
        e = { "光标下的错误浮窗口" },
        j = { "下一个错误" },
        k = { "上一个错误" },
    },
    x = {
        name = 'Trouble',
        x = {'Toggle'},
        w = {'工作区(workspace_diagnostics)'},
        d = {'当前文件(document_diagnostics)'},
        q = {'quickfix'},
        l = {'loclist'},
        f = {'(引用)lsp_references'},
        t = {'lsp_type_definitions'},
        g = {'lsp_definitions'},
        p = {'telescope'},
    },
    p = {
        name = 'goto-preview',
        d = {'定义(definition)'},
        t = {'类型定义(type_definition)'},
        i = {'实现(implementation)'},
        q = {'退出(close all win)'},
        f = {'引用(references)'},
    },
    e = {
        name = 'hop',
        w = {'单词'},
        l = {'行'},
        c = {'字符'},
    },
    s = {
        name = 'spectre',
        w = {'搜索光标下的单词'},
        f = {'当前文件中搜索'},
        p = {'当前项目中搜索'},
    },
    b = {
        name = 'bufferline',
        c = {'关闭当前标签'},
        h = {'关闭左侧标签'},
        l = {'关闭右侧标签'},
        o = {'关闭其他标签'},
        p = {'关闭指定标签'},
        e = {'buffer浏览'},
        s = {'buffer浏览(水平分屏)'},
        v = {'buffer浏览(垂直分屏)'},
        t = {'buffer浏览Toggle'}
    },
    f = {
        name = "Telescope",
        m = { "marks" },
        b = { "buffers" },
        f = { "文件" },
        a = { "文件(all)" },
        g = { "grep" },
        h = { "tags" },
        o = { "最近文件" },
        p = { "项目" },
        c = { "git commits" },
        s = { "git status" },
        e = { "env" },
        t = { "todo" },
    },
    g = {
        name = 'gitsigns',
        j = {'跳转到下一个修改'},
        k = {'跳转到上一个修改'},
        s = {'stage当前光标下的修改'},
        S = {'stage当前文件的修改'},
        r = {'取消本地的修改(当前光标)'},
        R = {'取消本地的修改'},
        p = {'查看当前光标下的修改'},
        d = {'比较当前文件的修改'},
        D = {'比较当前文件的修改~'},
        u = {'取消stage的修改'},
        b = {'blame line'},
        t = {
            name = "toggle",
            d = {"toggle_deleted"},
            b = {"toggle_current_line_blame"},
        }
    },
    m = {
        name = 'toggleterm',
        ['1'] = {'终端1'},
        ['2'] = {'终端2'},
        ['3'] = {'终端3'},
        ['g'] = {'lazygit'},
    },
    d = {
        name = 'vimspector',
        g = {'启动'},
        e = {'结束'},
        c = {'继续'},
        t = {'添加断点'},
        d = {'清空全部断点'},
        j = {'step over'},
        k = {'step out'},
        l = {'step into'},
    },
}

wk.register(mappings, { prefix = "<space>" })

-- 常用命令
mappings = {
    name = '常用命令',
    ['q'] = '退出',
    ['1'] = {'文件浏览'},
    ['2'] = {'聚集文件浏览'},
    ['3'] = {'大纲'},
    ['4'] = {'loclist'},
    ['5'] = {'quickfix'},
    ['6'] = {'todolist'},
    ['<leader>1'] = {'终端1'},
    ['<leader>2'] = {'终端2'},
    ['<leader>3'] = {'终端3'},
    ['<leader>4'] = {'终端4'},
    ['g'] = {'跳转到定义(Trouble)'},
    ['gg'] = {'定义预览(goto_preview)'},
    ['ggg'] = {'定义预览(Lspsaga)'},
    ['r'] = {'重命名'},
    ['f'] = {'查找引用(Touble)'},
    ['ff'] = {'浮窗查找引用(goto_preview)'},
    ['fff'] = {'浮窗查找引用(Lspsaga)'},
    ['?'] = {'帮助'},
    ['m'] = {'code action'},
    ['='] = {'格式化'},
    ['b'] = {'buffer切换'},
    ['sf'] = {'当前文件中搜索'},
    ['sp'] = {'工作区中搜索'},
    ['sw'] = {'工作区中搜索当前单词'},
}
wk.register(mappings, { prefix = "<leader>" })

mappings = {
    --[[
    s = {
        v = {"垂直分屏"},
        h = {"水平分屏"},
        c = {"关闭当前分屏"},
        o = {"关闭其他分屏"},
        ['='] = {'相等比例'},
    },
    --]]
    g = {
        c = '行注释',
        b = '块注释',
    }
}
wk.register(mappings, { prefix = "" })


